<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="Dao.BookDao" %><%--
  Created by IntelliJ IDEA.
  User: Muerzhi
  Date: 2023/12/25
  Time: 19:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
  //    String id=request.getParameter("id");
  String name=request.getParameter("newName");
  String author=request.getParameter("newAuthor");
  String house=request.getParameter("newHouse");
  String money=request.getParameter("newMoney");
  String content=request.getParameter("newContent");

  BookDao bookDao = new BookDao();
  int i = bookDao.insertBook(name, author, house, money,content);

  if (i!=0){
    out.println("<script>");
    out.println("alert('书籍《"+name+"》添加成功');");
    out.println("location.href='index.jsp#content2'");
    out.println("</script>");
  }else{
  out.println("<script>");
  out.println("alert('添加失败');");
  out.println("location.href='index.jsp#content2'");
  out.println("</script>");
}
%>
</body>
</html>
